package com.ys.controller.api.inter;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ys.constant.AppConstant;
import com.ys.entity.sys.TsUserInfo;
import com.ys.util.jwt.JwtUtil;
import com.ys.vo.A;

import lombok.AllArgsConstructor;
import lombok.Data;

@Controller
@RequestMapping("/api/inter/mine")
public class ApiInterMineController {
	private static final Logger logger = LoggerFactory.getLogger(ApiInterMineController.class);

    @RequestMapping("/personalInfo")
	@ResponseBody
	public A personalInfo(HttpServletRequest request) {
		try {
			String loginUserId = JwtUtil.getUserIdFromRequest(request);

			TsUserInfo tsUserInfo = new TsUserInfo().setUserId(loginUserId).queryFirst();
			String avatar = AppConstant.URL_AVATAR;
			String nickName = tsUserInfo.getUserName() + "(" + loginUserId + ")";

			InfoDto dto = new InfoDto(avatar, nickName);
			return A.suc(dto);
		}catch (Exception e){
			logger.error("出错：",e.getMessage(),e);
			return A.err("系统获取信息出错！");
		}
	}
	@Data
	@AllArgsConstructor
	public static class InfoDto {
		
		private String avatar; // 头像链接地址
		private String nickName; // 昵称，如：费玉清(00254)
	}
}
